/*
package demo1;

import javax.swing.tree.TreeNode;

class Solution {
    int preIndex = 0;
    private TreeNode createTreeBypandI (int[] preorder, int[] inorder, int inbegin, int inend) {
        if (inbegin > inend) {
            return null;
        }
        TreeNode root = new TreeNode(preorder[preIndex]);
        int rootIndex = findIndexOfI (inorder,inbegin,inend,preorder[preIndex]);
        if (rootIndex == -1) {
            return null;
        }
        preIndex++;
        root.left = createTreeBypandI (preorder, inorder,inbegin,rootIndex - 1);
        root.right = createTreeBypandI (preorder, inorder,rootIndex + 1,inend);
        return root;
    }
    private int findIndexOfI (int[] inorder, int inbegin, int inend, int key) {
        for (int i = inbegin; i <= inend; i++) {
            if (inorder[i] == key) {
                return i;
            }
        }
        return -1;
    }
    public TreeNode buildTree(int[] preorder, int[] inorder) {
        if (preorder == null || inorder == null) {
            return null;
        }
        return createTreeBypandI (preorder, inorder, 0, inorder.length - 1);
    }
}*/
